package com.qing.administer.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qing.administer.entity.SysMenu;
import com.qing.administer.entity.SysRole;
import com.qing.administer.mapper.SysRoleMapper;
import com.qing.administer.service.SysRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 * 角色 服务实现类
 * </p>
 *
 * @author qing
 * @since 2021-09-17
 */
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {

	@Autowired
	private SysRoleMapper sysRoleMapper;

	@Override
	public Page<SysRole> findPage(Long current, Long size, String keyword) {
		Page<SysRole> page=new Page<>(current,size);
		QueryWrapper<SysRole> queryWrapper=new QueryWrapper<>();
		if(StringUtils.hasLength(keyword)){
			queryWrapper.likeRight("roleName",keyword);
		}
		return sysRoleMapper.selectPage(page,queryWrapper);
	}


	@Override
	public List<SysRole> selectSysUserRole(Long userId) {
		return sysRoleMapper.selectSysRoleByUserId(userId);
	}
}
